﻿var loginErrorHandlers = [
    loginError0,
    loginError1,
    loginError2,
    loginError3,
    loginError4
];

var joinErrorHandlers = [
    joinError0,
    joinError1,
    joinError2,
    joinError3,
    joinError4,
    joinError5,
    joinError6
];

// por favor passem-nos para um ficheiro a parte!
// YAY \0/ thanks =D we like it more to be away from those strange, rude functions o,o

function ajaxError() {
    // callback do error, ajax
    console.log('ajax error');
    alert('Error logging in.\nPlease try again later.');
}

function loginError0() {
    $('span#login-user').addClass('correct');
    $('span#login-pass').addClass('correct');
}

function loginError1($data) {
    console.log('error 1: Database error!');
    alert('Error logging in.\nPlease try again later.');
}

function loginError2($data) {
    $('span#login-user').removeClass('correct').addClass('error').prev().val('').focus();
    console.log('error 2');
}

function loginError3($data) {
    var input_pass = $('span#login-pass');
    input_pass.removeClass('correct').addClass('error').prev().val('');

    var input_user = $('span#login-user');

    if (input_user.hasClass('correct'))
        input_pass.prev().focus();

    console.log("error 3");
}

function loginError4($data) { // Successful login
    userLoggedIn();

    $('div.drop-down-form input').each(function () {
        if ($(this).attr('type') != 'submit')
            $(this).val('');
    });
    $('#login').removeClass('active').children('#login-form').hide();
    $('span#login-user').removeClass('error').removeClass('correct');
    $('span#login-pass').removeClass('error').removeClass('correct');
}

function joinError0($data) {

}

function joinError1($data) {

}

function joinError2($data) {

}

function joinError3($data) {

}

function joinError4($data) {

}

function joinError5($data) {

}


function joinError6($data) {
}
